/*
 * Created by Administrator on 2017/3/31.
 */
var Progress = require('../../../../src/libs/Progress');
var FinanceRecord = React.createClass({
    getDefaultProps: function () {
        return {
            data: []

        }
    },
    getInitialState:function () {
        return {
            data:this.props.data
        }
    },
    componentDidMount: function () {

    },
    render: function () {
        return (
            <div>
                {this.state.data.map(function (item, index) {
                    var financeStatusText = '';
                    var detailUrl = 'javascript:void(0)'
                    var F_Status = Number(item.F_Status);
                    switch (F_Status) {
                        case 1:
                            financeStatusText = '还款中';
                            detailUrl = item.FinancingUrl;
                            break;
                        case 2:
                            financeStatusText = '还款完成';
                            detailUrl = item.FinancingUrl;
                            break;
                        case 3:
                            financeStatusText = '融资完成';
                            detailUrl = item.ProjectUrl;
                            break;
                        case 4:
                            financeStatusText = '投标中';
                            detailUrl = item.ProjectUrl;
                            break;
                        case 5:
                            financeStatusText = '预热中';
                            detailUrl = item.ProjectUrl;
                            break;
                        case 6:
                            financeStatusText = '项目流标';
                            break;
                    }
                    var Amount = Number(item.Amount),_moreOver = false;
                    if(Amount < 10000){
                        Amount = UFormatter.formatMoney(Amount, 2);
                    }else{
                        Amount = UFormatter.formatMoney(Amount / 10000, 2);
                        _moreOver = true;
                    }
                    return (
                        <div className="item">
                            <h3>{item.ProjectName}
                                <span className={"tag "+((F_Status == 1 || F_Status == 2 || F_Status == 3) ? "tag-red" : (F_Status == 6 ? "tag-grey" : "tag-yellow" ))}>{financeStatusText}</span>
                            </h3>
                            <ul className="clearfix">
                                <li>融资金额：<b>{Amount}</b>{_moreOver?"万元":"元"}</li>
                                <li>融资利率：<b>{item.FinanceRate}</b>%</li>
                                <li>融资期限：{item.Duration}天</li>
                                <li>还款日期：{item.RepayBegin}</li>
                            </ul>
                            <a href={detailUrl} className="detail">融资详情&gt;&gt;</a>
                            <div className="progress-rate">
                                {/*<p className="progress"><span>30%</span><b><i></i></b></p><p>1000元起投</p>*/}
                                <Progress className="progress" type="line" percent={item.Progress}></Progress>
                            </div>
                        </div>
                    )
                })}
            </div>
        )
    }
})

module.exports = FinanceRecord;